import React, { useEffect, useState } from 'react';
//2 基于React.createRef 创建ref对象来获取想要的内容

export default function CaseTwo() {
  const [num, setNum] = useState(0);
  let box = React.createRef();
  const handle = () => {
    setNum(num + 1);
  };
  useEffect(() => {
    console.log(box);
  }, []);
  return (
    <>
      <div className='demo'>
        <span className='num' ref={box}>
          {num}
        </span>
        <button onClick={handle}>新增</button>
      </div>
    </>
  );
}
